#include "DebugOutputString.h"
#include "../Type/Vector2.h"
#include <gslib.h>

DebugOutputString* DebugOutputString::getInstance()
{
	static DebugOutputString inst;
	return &inst;
}

void DebugOutputString::outputConsole(const char* message, ...)
{
#if _DEBUG
	va_list arglist;
	char buffer[256];

	va_start(arglist, message);
	vsprintf(buffer, message, arglist);
	{
		std::cout << buffer;
	}
	va_end(arglist);
#endif
}

void DebugOutputString::outputDebugString(const char* message, ...)
{
#if _DEBUG
	va_list arglist;
	char buffer[256];

	va_start(arglist, message);
	vsprintf(buffer, message, arglist);
	{
		OutputDebugString(buffer);
	}
	va_end(arglist);
#endif
}

void DebugOutputString::debugDrawFont(const Vector2& pos, char* str, ...)
{
#if _DEBUG
	va_list arglist;
	char buffer[256];

	va_start(arglist, str);
	vsprintf(buffer, str, arglist);
	{
		gsFontParameter(GS_FONT_NORMAL, 20, "MS 明朝");
		gsTextPos(pos.x, pos.y);
		glColor4f(0.f, 0.f, 0.f, 1.f);
		gsDrawText(buffer);
		glColor4f(1.f, 1.f, 1.f, 1.f);
	}
	va_end(arglist);

#endif
}

void DebugOutputString::connectStr(const char* str, va_list* arglist, void (*func(const char*)))
{
	char buffer[256];
	va_start((*arglist), str);
	vsprintf(buffer, str, (*arglist));

	func(buffer);

	va_end((*arglist));
}